<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="ui" uri="http://com.am.tag" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="../common.jsp" %>
<%@ page import="com.system.dao.DoctorDao"%>
<%
	String record_id = request.getParameter("record_id");
	DoctorDao dao = new DoctorDao();
	Map<String,Object> map = dao.getReferralInfo(record_id);
	pageContext.setAttribute("map", map);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>转诊单</title>
    
     <script type="text/javascript">
    
    	function doSave()
    	{
    		if(doCheck())
    		{
    			var map = Form.formToBean("winForm");
		 		map.record_id = "${param.record_id}";
		 		map.create_time = new Date().toLocaleDateString();
		 	
		 		ajax.remoteCall("com.system.dao.DoctorDao:referral",[map],function(reply){
		 			var result = reply.getResult();
		 			if(result.type == "success")
		 			{
		 				 $("#leftFrame").attr("src","${path}/jsp/doctor/printReferral.jsp?record_id=${param.record_id}");
		 			}
		 		});
    		}
	 	}
    	
    	$().ready(function(){
    		$("#create_time").val(new Date().toLocaleDateString());
    		$("#print_time").val(new Date().toLocaleString());
    	});
    	
    	function doCheck()
    	{
	 		if($.trim($("#sick").val()) == ""){
	 			$("#sick").focus();
	 			alert("所患病必须填写！");
	 			return false;
	 		}
	 		
	 		if($("#hospital").val() == ""){
	 			alert("请选择转诊医院！");
	 			$("#hospital").focus();
				return false;
	 		}
	 		
	 		if($.trim($("#subject").val()) == ""){
	 			$("#subject").focus();
	 			alert("转诊科必须填写！");
	 			return false;
	 		}
	 		
	 		return true;
    	}
    	
    	
	 		
    
    </script>
 </head>
  
  <body style="overflow-x: hidden;overflow-y:hidden;">
  <form id="winForm">
  	  <input type="hidden" name="referral_id" id="referral_id" value="${map['id']}">
	  <div style="border-right:1px dashed #ccc;width:45%;height:500px;display:inline;float:left">
	  <center>
	  		<fieldset style="width :95%; height:100%; padding-top:65px;margin-left:15px" >
				<legend>转诊信息编辑</legend>
				<br/>
				<table cellSpacing="0" cellPadding="0" height="100%" border="0">
					<tr height="40px">
						<td>
							<div style="float:right">	
								<ui:Button type="save" onclick="doSave()">保存</ui:Button>&nbsp;&nbsp;
							</div>
						</td> 
					</tr>
					<tr height="50px">
						<td align="left">
							患病类型：&nbsp;<input name="sick" id="sick" value="${map['sick']}" class="textbox" style="width: 160px" />
						</td>
						
					</tr>
					<tr height="50px">
						<td align="left">转诊医院：&nbsp;
							<select id="hospital" name="hospital" style="width:160px;">
								  <option value="">--请选择--</option>
								  <option value ="0"  <c:if test="${map['hospital'] == 0}">selected</c:if> >华侨医院</option>
								  <option value ="1"  <c:if test="${map['hospital'] == 1}">selected</c:if> >南医三院</option>
								  <option value ="2"  <c:if test="${map['hospital'] == 2}">selected</c:if> >中山三院</option>
								  <option value ="3"  <c:if test="${map['hospital'] == 3}">selected</c:if> >白云区第二医院</option>
								  <option value ="4"  <c:if test="${map['hospital'] == 4}">selected</c:if> >中医院大学第一附属医院 </option>
								  <option value ="5"  <c:if test="${map['hospital'] == 5}">selected</c:if> >其他</option>
							</select>
						</td>
						
					</tr>
					<tr height="50px">
						<td align="left">
							转诊科目：&nbsp;<input name="subject" id="subject" value="${map['subject']}" class="textbox" style="width: 160px" />
						</td>
					</tr>
				</table>
			</fieldset>	
			</center>
	  </div> 
	</form>	  
 	  <div style="width:55%;height:100%;display:inline;float:right">
		<iframe id="leftFrame" name="leftFrame" src="${path}/jsp/doctor/printReferral.jsp?record_id=${param.record_id}" width="100%" height="100%" frameborder="0"></iframe>
	  </div>
	
  </body>
</html>